What is R?
R is a programming language and environment designed for performing
statistical analyses and visualizing data.
R is open source, meaning that users can legally modify and redistribute
software.
R is script-based, meaning that text is used to write programs and
automate tasks.
What is RStudio?
RStudio is an integrated development environment which provides a
user-friendly interface to work with R.
RStudio streamlines writing scripts and editing code and simplifies
managing data and files.
While RStudio is designed primarily for R, it is also compatible with
other programming languages such as Python and HTML.
Installing R and RStudio
Install R
R can be downloaded by first clicking the link here, followed by choosing the
correct operating system.
Download for Windows
On the R for Windows page select install R for the first time.
Next, select Download R-4.3.2 for Windows.
The .exe file should appear in your downloads to complete installation.
Download for Mac
On the R for mac page select the correct version of your operating
system.
The .pkg file should appear in your downloads to complete installation.
Install RStudio
Follow the link here to download
RStudio.
Scroll down and select the correct operating system to download.
The file should appear in your downloads to complete installation.
Getting Familiar with RStudio
RStudio Interface
For working with R we will use RStudio.
Make sure to launch RStudio instead of R to begin.
The RStudio interface can be seen below.

Scripts
A script is simply a text file which contains a sequence of commands for
R to perform.
Scripts must be run for R to perform desired tasks.
When ran, commands from the script are transferred to the command line
in the console where commands will be performed.
Any text preceded by a # will not be transferred to the command line.
Code in a script is read in sequence, order is important!
Scripts in RStudio are in a .R file format.

Console
The console is where commands in R are executed and results are shown.
Commands can be typed directly into the console in the command line, but
are more frequently ran as scripts.
Some results such as objects and plots are not shown in the console
If a script is not written correctly, the error will show up in the
console below the command that could not be executed.

Environment
Objects (functions, variables, tables, graphs) which are created are
shown in the environment.
For our purposes we will generally not save the environment from one
session to another.
The broom symbol at the top of the pane clears the environment
Objects are created with this notation in a script object_name <-
command()

Files and Plots
The bottom right pane is where you can view plots and files
Looking at the file pathway in the bottom right can be useful in setting
up working directories or understanding file pathways in your computer.
Graphs which are plotted that are not saved as objects will show up in
plots.


Packages
Packages are collections of functions created by other R users to add
functionality to R.
Packages are stored in libraries.
Packages must be installed before use.
Each script must load the required packages to complete that script
using library() and other commands.
We’ll cover more about packages once we begin using R.
Summary
R is an open source programming language using
text-based commands to complete tasks.
RStudio is an interface which streamlines the use of
the R programming language.
The RStudio interface includes four panes.
The script pane in the top left is where .R text files
containing sequences of commands are written.
The console pane in the bottom left is where R commands
are executed.
The environment in the top right shows objects which
have been created by R commands.
The bottom right pane shows files in the working
directory and plots.
Packages are installed and loaded in scripts to add
functionality to the R programming language.
Additional Resources